#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;
const int N=205;
int n,m;
char mp[N][N];
int ai,aj;
int ri,rj;
int dir[4][2]={{-1,0},{1,0},{0,-1},{0,1}};
struct node{
    int i,j,step;
    node(int i,int j,int step):i(i),j(j),step(step){}
};
bool vis[N][N];
int main(void){
    while(~scanf("%d%d",&n,&m)){
        for(int i=0;i<n;i++){
            scanf("%s",mp[i]);
            for(int j=0;j<m;j++){
                if(mp[i][j]=='a'){
                    ai=i;
                    aj=j;
                }
                else if(mp[i][j]=='r'){
                    ri=i;
                    rj=j;
                }
            }
        }
        bool flag=false;
        memset(vis,false,sizeof(vis));
        queue<node> q;
        q.push(node(ai,aj,0));
        while(!q.empty()){
            node tmp=q.front();
            q.pop();
            int ti=tmp.i;
            int tj=tmp.j;
            int ts=tmp.step;
            //printf("%d %d %d\n",ti,tj,ts);
            vis[ti][tj]=true;
            if(ti==ri && tj==rj){
                printf("%d\n",ts);
                flag=true;
                break;
            }
            for(int i=0;i<4;i++){
                int ii=ti+dir[i][0];
                int jj=tj+dir[i][1];
                if(vis[ii][jj] || ii<0 || ii>=n ||jj<0 || jj>=m || mp[ii][jj]=='#'){
                    continue;
                }
                if(mp[ii][jj]=='x'){
                    q.push(node(ii,jj,ts+2));
                }
                else{
                    q.push(node(ii,jj,ts+1));
                }
            }
        }
        if(!flag){
            printf("Poor ANGEL has to stay in the prison all his life.\n");
        }
    }
    return 0;
}